﻿<%@ Page Language="C#" MasterPageFile="~/PresentationLayer/Split.Master" AutoEventWireup="true"
    CodeBehind="ListaPerc.aspx.cs" Inherits="Distrackting.PresentationLayer.ListaPerc"
    Title="Distrackting: Lista do Percurso" %>

<%@ Register assembly="Microsoft.Live.ServerControls.VE" namespace="Microsoft.Live.ServerControls.VE.Extenders" tagprefix="cc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="side" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="rest" runat="server">
<div class="border large box">
<h1 class="pagetitle">Lista de Percursos</h1>
    <asp:GridView ID="GridView1" runat="server" AllowSorting="True" 
        AutoGenerateColumns="False" DataSourceID="PercursoDataSource" 
        CellPadding="4" ForeColor="#333333" GridLines="None">
        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
        <Columns>
            <asp:TemplateField HeaderText="Nome" SortExpression="nome">
                <ItemTemplate>
                    <a href='VerPerc.aspx?perc={<%# Eval("cod_percurso") %>}'><%# Eval("nome") %>  </a>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("nome") %>'></asp:TextBox>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Localidade partida" SortExpression="cod_partida">
                <ItemTemplate>
                    <asp:Label ID="Label4" runat="server" Text='<%# Eval("Localidade1.nome") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("cod_partida") %>'></asp:TextBox>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Ambito" SortExpression="cod_ambito">
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("Ambito.descricao") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("cod_ambito") %>'></asp:TextBox>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Dificuldade" SortExpression="cod_dificuldade">
                <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" 
                        Text='<%# Eval("Dificuldade.descricao") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("cod_dificuldade") %>'></asp:TextBox>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Tipo de Percurso" SortExpression="cod_tipo">
                <ItemTemplate>
                    <asp:Label ID="Label3" runat="server" 
                        Text='<%# Eval("Tipo_percurso.descricao") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("cod_tipo") %>'></asp:TextBox>
                </EditItemTemplate>
            </asp:TemplateField>
            
        </Columns>
        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <EditRowStyle BackColor="#999999" />
        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
    </asp:GridView>
    <asp:ObjectDataSource ID="PercursoDataSource" runat="server" 
        SelectMethod="getListaPercursoPesquisa" 
        TypeName="Distrackting.BusinessLayer.GerirPercursos">
        <SelectParameters>
            <asp:ControlParameter ControlID="DropDownLocalidade" Name="localidade" 
                PropertyName="SelectedValue" Type="String" />
            <asp:ControlParameter ControlID="DropDownDif" Name="dificuldade" 
                PropertyName="SelectedValue" Type="String" />
            <asp:ControlParameter ControlID="DropDownTipo_perc" Name="tipo" 
                PropertyName="SelectedValue" Type="String" />
            <asp:ControlParameter ControlID="DropDownAmbito" Name="ambito" 
                PropertyName="SelectedValue" Type="String" />
        </SelectParameters>
    </asp:ObjectDataSource>
    <br />
    <asp:Button ID="Button1" runat="server" Text="Pesquisa avançada" 
        onclick="Button1_Click" />
    <br />
    <asp:Panel ID="Panel1" runat="server" Visible="False">
    
    <br />
        <asp:Label ID="Label9" runat="server" Font-Bold="true" Text="PESQUISA :"></asp:Label>
        <br />
    <asp:Label ID="Label5" runat="server" Text="Por localidade :"></asp:Label>
    <asp:DropDownList ID="DropDownLocalidade" runat="server" 
        AppendDataBoundItems="True" DataSourceID="localidadeDataSource" 
            DataTextField="nome" DataValueField="nome" AutoPostBack="True">
        <asp:ListItem>(nenhuma)</asp:ListItem>
    </asp:DropDownList>
    <br />
    <asp:Label ID="Label6" runat="server" Text="Por dificuldade :"></asp:Label>
    <asp:DropDownList ID="DropDownDif" runat="server" AppendDataBoundItems="True" 
            DataSourceID="DificuldadeDataSource" DataTextField="descricao" 
            DataValueField="descricao" AutoPostBack="True">
        <asp:ListItem>(nenhuma)</asp:ListItem>
    </asp:DropDownList>
    <br />
    <asp:Label ID="Label7" runat="server" Text="Por âmbito do percurso :"></asp:Label>
    <asp:DropDownList ID="DropDownAmbito" runat="server" AppendDataBoundItems="True" 
            DataSourceID="AmbitoDataSource" DataTextField="descricao" 
            DataValueField="descricao" AutoPostBack="True">
        <asp:ListItem>(nenhuma)</asp:ListItem>
    </asp:DropDownList>
    <br />
    <asp:Label ID="Label8" runat="server" Text="Por tipo de percurso :"></asp:Label>
    <asp:DropDownList ID="DropDownTipo_perc" runat="server" AppendDataBoundItems="True" 
            DataSourceID="TipoDataSource" DataTextField="descricao" 
            DataValueField="descricao" AutoPostBack="True">
        <asp:ListItem>(nenhuma)</asp:ListItem>
    </asp:DropDownList>
        <br />
    <br />
    </asp:Panel>
    <asp:Button ID="Button2" runat="server" Height="24px" onclick="Button2_Click" 
        Text="Fechar pesquisa" Visible="False" Width="144px" />
    <asp:SqlDataSource ID="ListarPercursos_DataSource" runat="server" 
        ConnectionString="<%$ ConnectionStrings:DistracktingConnectionString1 %>" 
        
        
        SelectCommand="SELECT [cod_percurso], [nome], [distancia], [duracao], [rating_total] FROM [percurso] WHERE ([cod_partida] = @cod_partida)">
        <SelectParameters>
            <asp:ControlParameter ControlID="DropDownLocalidade" Name="cod_partida" 
                PropertyName="SelectedValue" Type="Object" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:ObjectDataSource ID="TipoDataSource" runat="server" 
        SelectMethod="getTipo_percurso" 
        TypeName="Distrackting.BusinessLayer.GerirTipoPercurso">
    </asp:ObjectDataSource>
    <asp:ObjectDataSource ID="AmbitoDataSource" runat="server" 
        SelectMethod="getAmbitos" TypeName="Distrackting.BusinessLayer.GerirAmbito">
    </asp:ObjectDataSource>
    <asp:ObjectDataSource ID="DificuldadeDataSource" runat="server" 
        SelectMethod="getDificuldades" 
        TypeName="Distrackting.BusinessLayer.GerirDificuldade">
    </asp:ObjectDataSource>
    <asp:ObjectDataSource ID="localidadeDataSource" runat="server" 
        SelectMethod="getLocalidades" 
        TypeName="Distrackting.BusinessLayer.GerirLocalidade">
    </asp:ObjectDataSource>
    </div>
</asp:Content>
